import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'

Vue.use(Vuex)

const req = require.context('./modules', false, /\.js$/)// 获取每个模块的js文件相对路径
const mModule = req.keys().map(req)
const mName = req.keys().map(item => {
  return item.split('./')[1]
}).map(item => { return item.split('.js')[0] })
console.log(req, 'req')
const obj = {}

mName.forEach((key, index) => {
  console.log('key', key)
  console.log('index', index)
  obj[key] = mModule[index].default
})
const store = new Vuex.Store({
  modules: obj,
  getters
})

export default store
